#!/bin/bash

source "$METIS_HOME"metis.config

#default is a full TCP
portRange=1-65535

while getopts "p:h:s:o:l:" key ; do
    case "${key}" in
        h) targetHost=${OPTARG};;
        p) portRange=${OPTARG};;
	s) speed=${OPTARG};;
	o) outputDir=${OPTARG};;
	l) loggingDir=${OPTARG};;
    esac
done

if [ ! ${targetHost} ]; then
	echo "Error - Host has not been specified"
	exit
fi

mkdir ${outputDir}/${targetHost} &>/dev/null

# until there is a control file keep sleeping
until cat "$controlFile" 2> /dev/null
do
        echo "Pentest paused - to resume create a file at ${controlFile}"
        sleep 30;
done

nmap -sS -vv -A -PN -"$speed" -p "$portRange" -oA "${outputDir}/${targetHost}/nmap-sSV-${portRange}-${targetHost}" "$targetHost" &> "${loggingDir}/nmap-sSV-${portRange}-${targetHost}.log"

